var _n13;
var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2KDefine = require("KDefine");
var $2BulletMgr = require("BulletMgr");
var $2Zombie = require("Zombie");
var $2BundleManager = require("BundleManager");
var $2AudioManager = require("AudioManager");
var $2Boss = require("Boss");
var $2TombStone = require("TombStone");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_BulletBase = _n13 = /* */function (_cc$Component8) {
  babel_inherits(n, _cc$Component8);
  var _super9 = babel_createSuper(n);
  function n() {
    var _this25;
    babel_classCallCheck(this, n);
    _this25 = _super9.apply(this, arguments);
    _this25.damage = 1;
    _this25.inUse = false;
    return _this25;
  }
  babel_createClass(n, [{
    key: "reset",
    value: function reset(e, t, a, _n14) {
      this.hitSound = a;
      this.volume = _n14;
      this.id = parseFloat(t);
      this.type = $2BulletMgr.default.instance().allItemArr[this.id].type;
      this.node.scale = $2BulletMgr.default.instance().allItemArr[this.id].scale;
      this.bulletEffect = $2BulletMgr.default.instance().allItemArr[this.id].bulletEffect;
      if (1 == this.type) {
        this.node.addComponent(cc.Sprite).spriteFrame = $2BundleManager.default.instance.getBundleRes("BundleTexture", "Bullet/" + $2BulletMgr.default.instance().allItemArr[this.id].bullet, cc.SpriteFrame);
        this.node.getComponent(cc.Sprite).type = cc.Sprite.Type.SLICED;
      } else {
        this.node.addComponent(sp.Skeleton).skeletonData = $2BundleManager.default.instance.getBundleRes("Spine", "bullet/" + $2BulletMgr.default.instance().allItemArr[this.id].bullet + "/" + $2BulletMgr.default.instance().allItemArr[this.id].bullet, sp.SkeletonData);
        this.node.getComponent(sp.Skeleton).animation = "newAnimation";
        this.node.getComponent(sp.Skeleton).loop = true;
      }
      this.inUse = true;
      this.node.opacity = 0;
      this.radius = $2BulletMgr.default.instance().allItemArr[this.id].radius;
      this.node.getComponent(cc.CircleCollider).radius = this.radius;
      this.effectScale = $2BulletMgr.default.instance().allItemArr[this.id].effectScale;
      this.node.getChildByName("bulletEffect").scale = this.effectScale;
      e && (this.damage = e);
      return this;
    }
  }, {
    key: "unuse",
    value: function unuse() {
      this.inUse = false;
    }
  }, {
    key: "reuse",
    value: function reuse() {
      this.inUse = true;
    }
  }, {
    key: "onHit",
    value: function onHit(e) {
      var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
      switch (this.id) {
        case 10:
        case 11:
        case 12:
        case 13:
        case 14:
        case 15:
        case 24:
          e.hurt(this.damage);
          break;
        case 19:
        case 20:
        case 21:
        case 26:
          if (2 == t) {
            e.hurt(this.damage);
          } else {
            e.frozen();
            e.hurt(this.damage, "", this.effectScale);
          }
          break;
        case 25:
          if (2 == t) {
            e.hurt(this.damage);
          } else {
            e.huangyou();
            e.hurt(this.damage, "", this.effectScale);
            $2BulletMgr.default.instance().removeBullet(this);
          }
          break;
        case 27:
          if (2 == t) {
            cc.Tween.stopAllByTarget(this.node);
            e.hurt(this.damage);
            this.hit1();
          } else {
            e.frozen();
            e.hurt(this.damage, this.bulletEffect, this.effectScale);
            $2BulletMgr.default.instance().removeBullet(this);
          }
          break;
        default:
          cc.Tween.stopAllByTarget(this.node);
          if (2 == t) {
            e.hurt(this.damage);
            this.hit1();
          } else {
            e.hurt(this.damage, this.bulletEffect, this.effectScale);
            $2BulletMgr.default.instance().removeBullet(this);
          }
      }
      $2AudioManager.default.instance.playEffect(this.hitSound, this.volume);
    }
  }, {
    key: "hit1",
    value: function hit1() {
      var _this26 = this;
      var e = this.node.getChildByName("bulletEffect").getComponent(sp.Skeleton);
      this.node.getChildByName("bulletEffect").active = true;
      if (1 == this.type) {
        this.node.getComponent(cc.Sprite).enabled = false;
      } else {
        this.node.getComponent(sp.Skeleton).enabled = false;
      }
      e.skeletonData = $2BundleManager.default.instance.getBundleRes("Spine", "effect/" + this.node.getComponent(_n13).bulletEffect + "/" + this.node.getComponent(_n13).bulletEffect, sp.SkeletonData);
      e.setAnimation(0, "newAnimation", false);
      e.setCompleteListener(function () {
        _this26.node.getChildByName("bulletEffect").active = false;
        $2BulletMgr.default.instance().removeBullet(_this26.node.getComponent(_n13));
        e.setCompleteListener(null);
      });
    }
  }, {
    key: "onHitBoss",
    value: function onHitBoss(e) {}
  }, {
    key: "onCollisionEnter",
    value: function onCollisionEnter(e, t) {
      if (this.inUse) {
        if (e.tag === $2KDefine.Tag.zombie) {
          var _t13 = e.node.getComponent($2Zombie.default);
          if (!_t13.inUse) {
            return;
          }
          this.onHit(_t13);
        } else if (e.tag == $2KDefine.Tag.bossLeg || e.tag == $2KDefine.Tag.bossHead) {
          if (e.tag == $2KDefine.Tag.bossLeg) {
            this.damage = this.damage / 5;
          } else {
            e.tag, $2KDefine.Tag.bossHead;
          }
          this.onHit($2Boss.default.instance, 2);
        } else {
          e.tag == $2KDefine.Tag.tombstone && this.onHit(e.node.getComponent($2TombStone.default), 2);
        }
      }
    }
  }, {
    key: "onDestroy",
    value: function onDestroy() {
      $2BulletMgr.default.instance().removeFromPool(this.node);
    }
  }]);
  return n;
}(cc.Component);
def_BulletBase = _n13 = cc__decorate([ccp_ccclass], def_BulletBase);
exports.default = def_BulletBase;